package com.ghost.view.login
{
	import com.ghost.UI.Ghost_txt;
	import com.ghost.data_struct.HashMap;
	import com.ghost.manager.Load_manager;
	import com.ghost.manager.Tip_manager;
	import com.ghost.model.Configure_url;
	import com.ghost.model.Global_data;
	import com.ghost.model.Loading_data;
	import com.ghost.model.Object_pool;
	import com.ghost.view.Base_effect;
	
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	/**
	 * 选择服务器 
	 * @author ghost
	 */	
	public class Select_server extends Base_effect
	{
		private var data_arr:Array;//服务器列表数据;
		private var list_mc:Sprite;//列表容器
		private var list_max:int = 10;//最多可视范围列表条数 
		private var list_cell:Ghost_txt;
		private var title_img:Bitmap;//标题
		private var bg_mc:Global_pop_bg;//背景容器
		private var mutual_container_y:Number=100;//交互容器的y值
		
		public var ip:String;
		public var port:String;
		private var w:Number=1000;
		private var h:Number=600;
		public function Select_server(server_bg_mc:Bitmap)
		{
			this.addChild(server_bg_mc);
			title_img = new Bitmap(Object_pool.loaded_obj_pool.get("login_ui").get("server_tilte"));
			bg_mc = new Global_pop_bg(370,null,title_img,21);
			bg_mc.x = w/2-bg_mc.width/2;
			bg_mc.y = h/2-bg_mc.height/2;
			this.addChild(bg_mc);
			data_arr = new Array();
			data_arr = Object_pool.data_obj_pool.get('server_xml').list;
			list_mc = new Sprite();
			var l:int = data_arr.length;
			var j:int=0;
			for(;j<l;j++)
			{
				list_cell = new Ghost_txt();
				list_cell.buttonMode = true;
				list_cell.mouseEnabl = false;
				list_cell.text = data_arr[j].content;
				list_cell.setTextFormate(new TextFormat(null,14,0xffffff));
				list_cell.autoSize = TextFieldAutoSize.LEFT;
				list_cell.name = String(j);
				list_cell.filters=[new GlowFilter()];
				list_cell.addEventListener(MouseEvent.CLICK,list_Handler);
				list_mc.addChild(list_cell);
				list_cell.y = (list_cell.height+3)*j;
				Tip_manager.getInstance().add_tip(list_cell,data_arr[j].id,"server_xml");
			}
			this.addChild(list_mc);
			list_mc.x = bg_mc.width/2-list_mc.width/2+bg_mc.x;
			list_mc.y = bg_mc.y+mutual_container_y;
			//bg_mc.reflash();
		}
		private function list_Handler(e:MouseEvent):void
		{
			ip = data_arr[int(e.currentTarget.name)].ip;
			port = data_arr[int(e.currentTarget.name)].port;
			this.dispatchEvent(new Event('server_end'));
		}
	}
}